<template>
	<view>
		<view class="wrap">
			<view class="w-swiper">
				<u-swiper :list="list" border-radius="10" interval="5000"></u-swiper>
			</view>

			<view class="content" v-if="type == 2">
				<view class="content-title">
					供货商
				</view>
				<u-grid :col="4" :border="false">
					<u-grid-item @click="goPage('/pages/farm/supNoStockList')">
						<view class="ite">
							<u-icon name="photo" :size="40" color="#fff"></u-icon>
						</view>
						<view class="grid-text">配货订单</view>
					</u-grid-item>
					<u-grid-item @click="goPage('/pages/farm/supHistorylist')">
						<view class="ite">
							<u-icon name="photo" :size="40" color="#fff"></u-icon>
						</view>
						<view class="grid-text">历史订单</view>
					</u-grid-item>
					<u-grid-item @click="goPage('/pages/supList/supList')">
						<view class="ite">
							<u-icon name="photo" :size="40" color="#fff"></u-icon>
						</view>
						<view class="grid-text">菜品定价</view>
					</u-grid-item>
				</u-grid>
			</view>
			
			<view class="content" v-if="type == 3">
				<view class="content-title">
					农贸
				</view>
				<u-grid :col="4" :border="false">
					<u-grid-item @click="goPage('../addUserInfo2/addUserInfo2')">
						<view class="ite blue">
							<u-icon name="man-delete" :size="40" color="#fff"></u-icon>
						</view>
						<view class="grid-text">添加供应商</view>
					</u-grid-item>
					
					<u-grid-item @click="goPage('../addGoods/addGoods')">
						<view class="ite blue">
							<u-icon name="man-delete" :size="40" color="#fff"></u-icon>
						</view>
						<view class="grid-text">添加商品</view>
					</u-grid-item>
					
					<u-grid-item @click="goPage('/pages/nmCaiList/nmCaiList')">
						<view class="ite blue">
							<u-icon name="man-delete" :size="40" color="#fff"></u-icon>
						</view>
						<view class="grid-text">菜品列表</view>
					</u-grid-item>
					
					<u-grid-item @click="goPage('../gongHuoShangGuanLi/gongHuoShangGuanLi')">
						<view class="ite blue">
							<u-icon name="man-delete" :size="40" color="#fff"></u-icon>
						</view>
						<view class="grid-text">供货商管理</view>
					</u-grid-item>
					
					<u-grid-item>
						<view class="ite blue" @click="goPage('/pages/farm/nmdeliveryList')">
							<u-icon name="man-delete" :size="40" color="#fff"></u-icon>
						</view>
						<view class="grid-text">配送列表</view>
					</u-grid-item>
					
					<u-grid-item>
						<view class="ite blue" @click="goPage('/pages/farm/nmPickingList')">
							<u-icon name="man-delete" :size="40" color="#fff"></u-icon>
						</view>
						<view class="grid-text">拣货列表</view>
					</u-grid-item>
					
					<u-grid-item>
						<view class="ite blue" @click="goPage('/pages/farm/nmStockList')">
							<u-icon name="man-delete" :size="40" color="#fff"></u-icon>
						</view>
						<view class="grid-text">备货列表</view>
					</u-grid-item>
					
					<u-grid-item>
						<view class="ite blue" @click="goPage('/pages/farm/nmHistorylist')">
							<u-icon name="man-delete" :size="40" color="#fff"></u-icon>
						</view>
						<view class="grid-text">历史订单</view>
					</u-grid-item>
					
					
				</u-grid>
			</view>
			
			<view class="content" v-if="type == 0 || type == 1">
				<view class="content-title">
					校区和客户
				</view>
				<u-grid :col="4" :border="false">
					<u-grid-item @click="goPage('../goodsList/goodsList')">
						<view class="ite">
							<u-icon name="man-delete" :size="40" color="#fff"></u-icon>
						</view>
						<view class="grid-text">预定菜品</view>
					</u-grid-item>
					
					<u-grid-item @click="goPage('/pages/farm/schoolHistorylist')">
						<view class="ite">
							<u-icon name="man-delete" :size="40" color="#fff"></u-icon>
						</view>
						<view class="grid-text">订单列表</view>
					</u-grid-item>
					
				</u-grid>
			</view>


			<view class="content">
				<view class="content-title">
					个人信息
				</view>
				<u-grid :col="4" :border="false">
				<!-- 	<u-grid-item @click="goPage('/pages/user/register')">
						<view class="ite blue">
							<u-icon name="account" :size="40" color="#fff"></u-icon>
						</view>
						<view class="grid-text">资料修改</view>
					</u-grid-item> -->
					<u-grid-item @click="logout">
						<view class="ite blue">
							<u-icon name="man-delete" :size="40" color="#fff"></u-icon>
						</view>
						<view class="grid-text">退出</view>
					</u-grid-item>
				</u-grid>
			</view>


		</view>
	</view>
</template>
<script>
	export default {
		data() {
			return {
				titles: "...",
				list: [{
						image: 'https://cdn.uviewui.com/uview/swiper/1.jpg',
						title: '昨夜星辰昨夜风，画楼西畔桂堂东'
					},
					{
						image: 'https://cdn.uviewui.com/uview/swiper/2.jpg',
						title: '身无彩凤双飞翼，心有灵犀一点通'
					},
					{
						image: 'https://cdn.uviewui.com/uview/swiper/3.jpg',
						title: '谁念西风独自凉，萧萧黄叶闭疏窗，沉思往事立残阳'
					}
				],
				userinfo: "",
				type:"0", // 0学校 1客户 2供养商 3农贸 
			}
		},
		onLoad() {
			//alert(userinfo);
			this.baseurl = this.$u.http.config.baseUrl
			this.userinfo = uni.getStorageSync('userinfo');
			if(!uni.getStorageSync("token")){
				uni.redirectTo({
					url: '../login/login'
				})
			}
		},
		onShow() {
			
			var datatype=this.userinfo.datatype;
			//var datatype=this.userinfo.datatype;
			let type = 0;
			if(datatype == 2){ //供养商
				type = datatype
			}else if(this.userinfo.bumen == "农贸"){
				type = 3
				this.titles="农贸";
			}else if(datatype == 1){
				this.titles="客户";
			}else if(this.userinfo.is_schoolmaner){
				this.titles="学校";
				type = 0;
			}
			this.type = type
		},
		computed: {},
		methods: {
			goPage(url) {
				setTimeout(() => {
					uni.navigateTo({
						url: url
					});
				}, 500)
			},
			logout() {
				uni.removeStorageSync("token")
				uni.removeStorageSync("userinfo")
				uni.redirectTo({
					url: '../login/login'
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.w-swiper {
		margin: 15rpx 20rpx 50rpx;
		overflow: hidden;
	}

	.content {
		padding: 0rpx 30rpx 20rpx;

		.title {
			width: 100%;
			height: 150rpx;
			text-align: center;
			line-height: 100rpx;
			font-size: 60rpx;
		}

		.content-title {
			font-size: 26rpx;
			font-weight: bold;
			margin-bottom: 15rpx;
		}

		.ite {
			width: 80rpx;
			height: 80rpx;
			background-color: #ffaa00;
			border-radius: 15rpx;
			vertical-align: center;
			display: flex;
			align-items: center;
			justify-content: center;
		}

		.blue {
			background-color: RGB(49, 138, 253);
		}

		.fense {
			background-color: #ffaa00;
		}

		.red {
			background-color: RGB(254, 115, 9);
		}

		.whtie {
			background-color: #fff;
		}

		.shenlan {
			background-color: RGB(50, 112, 247);
		}

		.lvse {
			background-color: RGB(0, 210, 185);
		}

		.grid-text {
			font-size: 24rpx;
			margin-top: 4rpx;
			color: #333;
		}
	}
</style>
